package com.jtbd.config;


import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.util.matcher.RegexRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

@Data
@Configuration
@ConfigurationProperties(prefix = "security.whitelist")
public class SecurityWhiteUrlConfig {
       private String staticPattern;
    private String apiDocPattern;
    private String jtbdApiWhitePattern;

    /**
     * 获取静态资源白名单请求匹配器
     *
     * @return RequestMatcher 静态资源白名单请求匹配器实例
     */
    public RequestMatcher getWhiteListStaticMatcher() {
        return new RegexRequestMatcher(staticPattern, null);
    }

    /**
     * 获取API文档白名单请求匹配器
     *
     * @return RequestMatcher API文档白名单请求匹配器实例
     */
    public RequestMatcher getWhiteListApiDocMatcher() {
        return new RegexRequestMatcher(apiDocPattern, null);
    }

    /**
     * 获取自定义API白名单请求匹配器
     *
     * @return RequestMatcher 自定义API白名单请求匹配器实例
     */
    public RequestMatcher getWhiteListCustomApiMatcher() {
        return new RegexRequestMatcher(jtbdApiWhitePattern, null);
    }

}
